#!perl

use Test::More tests => 19;
use lib "lib";

$ENV{JOOSE_INC} = "localLib/root1;localLib/root2;localLib/root3";

use Joose::Librarian;
use Data::Dump qw(dd ddx);

#================================================================================================================================================================================================================================================
#book A
#================================================================================================================================================================================================================================================
my $a = Joose::Librarian->get_book('A');

$a->extract_all_dependencies();

is(keys(%{$a->all_dependencies}), 4, "A: Extracted correct number of All dependencies");

is($a->all_dependencies->{'D'}->{Module}, 'D', "A: .. got D among them");
is($a->all_dependencies->{'E'}->{Module}, 'E', "A: .. got E among them");
is($a->all_dependencies->{'G'}->{Module}, 'G', "A: .. got G among them");
is($a->all_dependencies->{'H'}->{Module}, 'H', "A: .. got H among them");
is($a->all_dependencies->{'H'}->{version}, 0.2, "A: .. and H is at correct version");


#================================================================================================================================================================================================================================================
#book D
#================================================================================================================================================================================================================================================
my $d = Joose::Librarian->get_book('D');

$d->extract_all_dependencies();

is(keys(%{$d->all_dependencies}), 2, "D: Extracted correct number of All dependencies");

is($d->all_dependencies->{'G'}->{Module}, 'G', "D: .. got G among them");
is($d->all_dependencies->{'H'}->{Module}, 'H', "D: .. got H among them");
is($d->all_dependencies->{'H'}->{version}, 0.1, "D: .. and H is at correct version");


#================================================================================================================================================================================================================================================
#book E
#================================================================================================================================================================================================================================================
my $e = Joose::Librarian->get_book('E');

$e->extract_all_dependencies();

is(keys(%{$e->all_dependencies}), 1, "E: Extracted correct number of All dependencies");

is($e->all_dependencies->{'H'}->{Module}, 'H', "E: .. got H among them");
is($e->all_dependencies->{'H'}->{version}, 0.2, "E: .. and H is at correct version");


#================================================================================================================================================================================================================================================
#book C
#================================================================================================================================================================================================================================================
my $c = Joose::Librarian->get_book('C');

$c->extract_all_dependencies();

is(keys(%{$c->all_dependencies}), 0, "C: Extracted correct number of All dependencies");


#================================================================================================================================================================================================================================================
#book H
#================================================================================================================================================================================================================================================
my $h = Joose::Librarian->get_book('H');

$h->extract_all_dependencies();

is(keys(%{$h->all_dependencies}), 0, "H: Extracted correct number of All dependencies");


#================================================================================================================================================================================================================================================
#book B
#================================================================================================================================================================================================================================================
my $b = Joose::Librarian->get_book('B');

$b->extract_all_dependencies();

is(keys(%{$b->all_dependencies}), 3, "B: Extracted correct number of All dependencies");
is($b->all_dependencies->{'F'}->{Module}, 'F', "B: .. got F among them");
is($b->all_dependencies->{'I'}->{Module}, 'I', "B: .. got I among them");
is($b->all_dependencies->{'J'}->{Module}, 'J', "B: .. got J among them");
